﻿<UserControl 
    x:Class="MyFloridaHouse.SilverlightOpenDistricts.xyFileOpen"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="447" d:DesignWidth="399"
     xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
    Visibility="{Binding isFileOpenActive, Converter={StaticResource ConvertBoolToVisibility}}"
    >

    <Border Margin="0"  CornerRadius="20" BorderBrush="#FF549D9D"  BorderThickness="2"  
            Background="{StaticResource MainPageBackgroundBrush}"
            >

        <Grid Margin="5" >
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid Margin="15" Grid.Row="0" Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Column="0">
                    <sdk:Label Content="District Plan Open" Style="{StaticResource lblTitleStyle}" Margin="5" HorizontalAlignment="Left"/>
                </StackPanel>

            </Grid>

            <StackPanel  Grid.Row="1" Grid.Column="0"  Orientation="Horizontal" HorizontalAlignment="Left" Margin="5">
                <Button x:Name="CancelButton" Content="Cancel" Command="{Binding CmdFileOpenCancel}" Width="75" Height="23" HorizontalAlignment="Right" Margin="5"  />
                <Button x:Name="OKButton" Content="OK" Command="{Binding CmdFileOpenOK}" Width="75" Height="23" HorizontalAlignment="Right" Margin="5"  />
            </StackPanel>
            
            <sdk:Label Grid.Row="2" Grid.Column="0"  HorizontalAlignment="Left"  Margin="5" Content="Select a Plan to load ..." />

            <sdk:Label Grid.Row="3" Grid.Column="1"  HorizontalAlignment="Left"  Margin="5" Content="{Binding fileOpenFileName, Mode=TwoWay}" />

            <StackPanel   Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Left" Margin="5">
                <RadioButton  Margin="2" Height="20"  Content="Cloud"            GroupName="StorageGroup" IsChecked="{Binding fileOpenFileSource, Mode=TwoWay, Converter={StaticResource ConvertEnumToBool}, ConverterParameter=CLOUD}" />
                <RadioButton  Margin="2" Height="20"  Content="Local"            GroupName="StorageGroup" IsChecked="{Binding fileOpenFileSource, Mode=TwoWay, Converter={StaticResource ConvertEnumToBool}, ConverterParameter=LOCAL}" />
                <RadioButton  Margin="2" Height="20"  Content="Local Isolated"   GroupName="StorageGroup" IsChecked="{Binding fileOpenFileSource, Mode=TwoWay, Converter={StaticResource ConvertEnumToBool}, ConverterParameter=ISOLATED}" />
            </StackPanel>
            
            <Border   Grid.Row="5"  Margin="10,2"  CornerRadius="20" BorderBrush="DarkBlue"  
                    BorderThickness="1"  
                    Background="{StaticResource MainPageBackgroundBrush}"
                    >
                <Grid Margin="15">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <ListBox Grid.Row="0" Grid.Column="0" Margin="0"   
                                     ItemsSource="{Binding fileOpenFileNameList}"  
                                     SelectedIndex="{Binding fileOpenFileNameListSelectedIndex, Mode=TwoWay}" Background="Azure" 
                                     VerticalAlignment="Stretch"
                                     HorizontalAlignment="Stretch"
                            >
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel UseLayoutRounding="True" />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                        <ListBox.Template>
                            <ControlTemplate>
                                <ScrollViewer>
                                    <ItemsPresenter />
                                </ScrollViewer>
                            </ControlTemplate>
                        </ListBox.Template>
                        <ListBox.ItemTemplate >
                            <DataTemplate >
                                <sdk:Label Content="{Binding fileName}"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>

                    </ListBox>

                </Grid>
            </Border>


        </Grid>
    </Border>
</UserControl>
